<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>localstorage</title>
</head>
<body>
<button onclick="save()">save</button>
<button onclick="read()">read</button>
<button onclick="deleted()">delete</button>
<button onclick="cleanAll()">cleanAll</button>
</body>
<script type="text/javascript">
  let p ={name:'张三',age:13}
  function save(){
    window.localStorage.setItem('msg','hello!')
    window.localStorage.setItem('msg3',233)
    window.localStorage.setItem('msg4',JSON.stringify(p))
  }
  function read(){
      console.log(window.localStorage.getItem('msg'))
      console.log(JSON.parse(window.localStorage.getItem('msg4')) )
     }
  function deleted(){
    window.localStorage.removeItem('msg')
    }
    function cleanAll(){
    window.localStorage.clear()
    }
</script>
</html>
